package com.stox.manager.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.stox.manager.ExchangeManager;
import com.stox.model.entity.ExchangeEntity;
import com.stox.repository.ExchangeRepository;

@Component
@Transactional
public class ExchangeManagerImpl implements ExchangeManager{

	@Autowired
	private ExchangeRepository exchangeRepository;
	
	@Override
	public long count() {
		return exchangeRepository.count();
	}
	
	@Override
	public List<ExchangeEntity> findAll() {
		return exchangeRepository.findAll();
	}
	
	@Override
	public List<ExchangeEntity> findByCountryCode(String countryCode) {
		return exchangeRepository.findByCountryCode(countryCode);
	}

	@Override
	@Transactional
	public ExchangeEntity save(ExchangeEntity exchange) {
		return exchangeRepository.save(exchange);
	}
	
	@Override
	public ExchangeEntity findOne(String code) {
		return exchangeRepository.findOne(code);
	}

}
